﻿package com.shangda.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.shangda.dao.RunDataDao;
import com.shangda.entity.ReceiveData;
import com.shangda.util.JdbcUtil;

public class RunDataDaoImple implements RunDataDao{

	public void insertRunData(ReceiveData receiveData) throws Exception {
		Connection con = JdbcUtil.getConnection();
		String sql = "insert into run_data(sewageID,testingtime,equipment1state,equipment2state," +
				     "equipment3state,equipment4state,equipment5state,equipment6state,equipment7state," +
				     "equipment8state,equipment9state,equipment10state,equipment11state,equipment12state," +
				     "equipment13state,equipment14state,equipment15state,equipment16state,equipment17state," +
				     "equipment18state,equipment19state,equipment20state,equipment21state) values(?,?,?,?,?,?,?," +
				     "?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setInt(1, receiveData.getSewageId());
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
		Date date = new Date();
		ps.setString(2, formatter.format(date));
		ps.setInt(3, receiveData.getPumpStatus1());
		ps.setInt(4, receiveData.getPumpStatus2());
		ps.setInt(5, receiveData.getPumpStatus3());
		ps.setInt(6, receiveData.getPumpStatus4());
		ps.setInt(7, receiveData.getPumpStatus5());
		ps.setInt(8, receiveData.getElevateLs());
		ps.setInt(9, receiveData.getWaterLs());
		ps.setInt(10, receiveData.getPumpStatus()[0]);
		ps.setInt(11, receiveData.getPumpStatus()[1]);
		ps.setInt(12, receiveData.getPumpStatus()[2]);
		ps.setInt(13, receiveData.getPumpStatus()[3]);
		ps.setInt(14, receiveData.getPumpStatus()[4]);
		ps.setInt(15, receiveData.getPumpStatus()[5]);
		ps.setInt(16, receiveData.getPumpStatus()[6]);
		ps.setInt(17, receiveData.getPumpStatus()[7]);
		ps.setInt(18, receiveData.getPumpStatus()[8]);
		ps.setInt(19, receiveData.getPumpStatus()[9]);
		ps.setInt(20, receiveData.getPumpStatus()[10]);
		ps.setInt(21, receiveData.getPumpStatus()[11]);
		ps.setInt(22, receiveData.getPumpStatus()[12]);
		ps.setInt(23, receiveData.getPumpStatus()[13]);
		ps.execute();
		JdbcUtil.release(null, ps, con);
		
	}

}
